package com.chendongyang.www.service;
import com.chendongyang.www.po.appointment;
import com.chendongyang.www.dao.reservations;
import com.chendongyang.www.util.userId;
import  com.chendongyang.www.dao.charge;
import  com.chendongyang.www.po.appointment1;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;

public class reservation {
    public  void  reservating() throws SQLException {
        //进行充电位的预约；
        reservations udi=new reservations();
        charge udi1=new charge();
        Scanner input = new Scanner(System.in);
        System.out.println("现有可预约的充电口有：");
        ArrayList<appointment> list=new ArrayList<>();
        list=udi.select();
        int num=list.size();
        for(int i=0;i<num;i++){
            System.out.print(i+1+"  ");
            System.out.println(list.get(i));
        }
        System.out.println("请输入要预约的时间段对应的选项");
        int op=input.nextInt();
        boolean check1=udi1.select2(userId.Id);
        if(check1==false){
            System.out.println("您的电动车还没有上牌，无法进行预约");
            return;
        }
        int line=udi.update(list.get(op-1).getChargeS(),list.get(op-1).getChargeB(),userId.Id);
        if(line==1) System.out.println("预约成功");
        else System.out.println("预约失败");
    }
    public  void  reservating1() throws SQLException {
        reservations udi=new reservations();
        Scanner input = new Scanner(System.in);
        System.out.println("现有可预约的停车位有：");
        ArrayList<appointment1> list=new ArrayList<>();
        list=udi.select1();
        int num=list.size();
        for(int i=0;i<num;i++){
            System.out.print(i+1+"  ");
            System.out.println(list.get(i));
        }
        System.out.println("请输入要预约的时间段对应的选项");
        int op=input.nextInt();
        int line=udi.update1(list.get(op-1).getParkingS(),list.get(op-1).getParkingB(),userId.Id);
        if(line==1) System.out.println("预约成功");
        else System.out.println("预约失败");
    }
}
